package com.ssy.lingxi.marketing.controller.web;

import com.ssy.lingxi.common.controller.BaseController;
import com.ssy.lingxi.common.model.dto.UserLoginCacheDTO;
import com.ssy.lingxi.common.response.PageData;
import com.ssy.lingxi.common.response.Wrapper;
import com.ssy.lingxi.marketing.api.model.request.GroupPurchaseDetailRequest;
import com.ssy.lingxi.marketing.api.model.request.GroupPurchasePageRequest;
import com.ssy.lingxi.marketing.api.model.request.OrderGroupPurchaseDetailRequest;
import com.ssy.lingxi.marketing.api.model.request.OrderListGroupPurchaseRequest;
import com.ssy.lingxi.marketing.api.model.response.GroupPurchaseDetailResponse;
import com.ssy.lingxi.marketing.api.model.response.GroupPurchaseListResponse;
import com.ssy.lingxi.marketing.api.model.response.GroupPurchaseShareDetailResponse;
import com.ssy.lingxi.marketing.api.model.response.OrderListGroupPurchaseResponse;
import com.ssy.lingxi.marketing.service.IActivityOrderService;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import javax.validation.Valid;
import java.util.List;

/**
 * @menu Web - 活动订单(拼团)
 * @author ds
 * @version 2.0.0
 * @date 2021/11/23
 */
@RestController
@RequestMapping("/marketing/web/activity/order")
public class WebActivityOrderController extends BaseController {

    @Resource
    private IActivityOrderService activityOrderService;
    /**
     * 拼团列表
     **/
    @RequestMapping(value = "/group/purchase/list", method = RequestMethod.POST)
    public Wrapper<PageData<GroupPurchaseListResponse>> getGroupPurchaseList(@Valid @RequestBody GroupPurchasePageRequest request) {
        UserLoginCacheDTO loginUser = isLogin() ? getSysUser() : null;
        return activityOrderService.getGroupPurchaseList(loginUser, request);
    }

    /**
     * 拼团详情(拼团id)
     **/
    @RequestMapping(value = "/group/purchase/detail", method = RequestMethod.POST)
    public Wrapper<GroupPurchaseDetailResponse> getGroupPurchaseDetail(@Valid @RequestBody GroupPurchaseDetailRequest request) {
        UserLoginCacheDTO loginUser = isLogin() ? getSysUser() : null;
        return activityOrderService.getGroupPurchaseDetail(loginUser, request);
    }

    /**
     * 拼团详情（根据订单id）
     **/
    @RequestMapping(value = "/order/group/purchase/detail", method = RequestMethod.POST)
    public Wrapper<GroupPurchaseDetailResponse> getOrderGroupPurchaseDetail(@Valid @RequestBody OrderGroupPurchaseDetailRequest request) {
        return activityOrderService.getOrderGroupPurchaseDetail(getSysUser(), request);
    }

    /**
     * 订单列表拼团信息（根据订单ids）
     **/
    @RequestMapping(value = "/order/list/group/purchase", method = RequestMethod.POST)
    public Wrapper<List<OrderListGroupPurchaseResponse>> getOrderListGroupPurchase(@Valid @RequestBody OrderListGroupPurchaseRequest request) {
        return activityOrderService.getOrderListGroupPurchase(getSysUser(), request);
    }

    /**
     * 拼团分享信息查询（根据订单id）
     **/
    @RequestMapping(value = "/order/group/purchase/share/detail", method = RequestMethod.POST)
    public Wrapper<GroupPurchaseShareDetailResponse> getOrderGroupPurchaseShareDetail(@Valid @RequestBody OrderGroupPurchaseDetailRequest request) {
        return activityOrderService.getOrderGroupPurchaseShareDetail(getSysUser(), request);
    }
}
